#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''
Created 2011/12/01
@autor: Sérgio Santos
'''
import csv
import sqlite3
import Tkinter
import tkSimpleDialog

from Write_Html import *
from Write_Csv import *

class Prof_Degree_Estab_Year_Html():
		# mostra nome prof por grau, estabelecimento e por ano export para html e cria csv		
		def __init__(self):

			conexao = sqlite3.connect("treta.db")
			c = conexao.cursor()

			root = Tkinter.Tk()
			root.withdraw()
	
			year = tkSimpleDialog.askstring('Year','Qual o ano lectivo?')
			establishment = tkSimpleDialog.askstring('Establishment','Qual o Estabelecimento de ensino?')
			degree = tkSimpleDialog.askstring('Grau','Qual o grau do docente?')

			c.execute("SELECT nome FROM PROF WHERE ano_lectivo = '"+ str(year)+ 
				"' AND nome_estabelecimento = '"+establishment+"'AND ultimo_grau = '"+degree+"' ")
			lista = []
	
			for row in c.fetchall():
				lista.append(row)
				pass
	
			Write(lista)
	
			WriteCsv(lista)	
	
			root.destroy()

			conexao.commit() 

